import React, { Component } from 'react';
import { Text, View, Button } from 'react-native';

export default class Me extends Component {
  render() {
    const { navigation } = this.props;
    const msg = navigation.getParam('msg', 'NO-MSG');
    const itemId = navigation.getParam('itemId', 'NO-ID');
    const data = navigation.getParam('data', '我是默认值');
    const time = navigation.getParam('time', '我是默认值');
    const cb = navigation.getParam('cb', null);
    return (
      <View>
        <Text> textInComponent </Text>
        <Text>itemId: {JSON.stringify(itemId)}</Text>
        <Text> {JSON.stringify(data)}</Text>
        <Text>time: {JSON.stringify(time)}</Text>
        <Button
          title='带参数返回'
          onPress={() => {
            /* 1. Navigate to the Details route with params */
            // this.props.navigation.setParam('data', {
            //   itemId     : 86,
            //   otherParam : 'anything you want here',
            //   data       : { id: 123 },
            //   cb         : function() {
            //     alert('回来了');
            //   }

            // });

            this.props.navigation.goBack();
            cb(data);
          }}
        />
      </View>
    );
  }
}
